home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / gnu / grep / grep.lzh / README.sunos4 < prev    next >
Internet Message Format  |  1989-03-02  |  3KB

  1. Date:    Fri, 24 Feb 89 15:36:40 -0600
  2. To:      mike@wheaties.ai.mit.edu
  3. From:    Dave Cohrs <dave@cs.wisc.edu>
  4. Subject: bug + fix in gnu grep 1.2 (from prep.ai.mit.edu)
  5.  
  6. I tried installing the GNU grep 1.2 on a Sun4 running 4.0.1 and
  7. "Spencer test #36" failed.  After some experimenting, I found and
  8. fixed the bug.  Well, actually, the bug in the the C compiler, but
  9. I managed a workaround.
  10.  
  11. Description:
  12.  
  13. The Sun4 4.0.1 C compiler with -O doesn't generate the correct for
  14. statements of the form
  15.     if("string")
  16.         x;
  17.     else
  18.         y;
  19. To be exact, "y;" gets executed, while "x;" should.  This causes the
  20. #define FETCH() to fail for test #36.
  21.  
  22. Fix:
  23.  
  24. In an #ifdef sparc in dfa.c, I made two versions of FETCH, FETCH0() and
  25. the regular FETCH().  The former takes only one argument, the latter
  26. expects its 2nd argument to contain a non-nil string.  This removes
  27. the need to test the constant strings, and the compiler bug isn't
  28. exercised.  I then changed the one instance of FETCH() with a nil
  29. second argument to be FETCH0() instead.
  30.  
  31. dave cohrs
  32.  
  33. ===================================================================
  34. RCS file: RCS/dfa.c,v
  35. retrieving revision 1.1
  36. diff -c -r1.1 dfa.c
  37. *** /tmp/,RCSt1a05930    Fri Feb 24 15:32:33 1989
  38. --- dfa.c    Fri Feb 24 15:23:34 1989
  39. ***************
  40. *** 285,293 ****
  41. --- 285,315 ----
  42.                      is turned off). */
  43.   
  44.   /* Note that characters become unsigned here. */
  45. + #ifdef sparc
  46. + /*
  47. +  * Sun4 4.0.1 C compiler can't compare constant strings correctly.
  48. +  * e.g. if("test") { x; } else { y; }
  49. +  * the compiler will not generate code to execute { x; }, but
  50. +  * executes { y; } instead.
  51. +  */
  52. + #define FETCH0(c)                 \
  53. +   {                         \
  54. +     if (! lexleft)                 \
  55. +       return _END;                 \
  56. +     (c) = (unsigned char) *lexptr++;  \
  57. +     --lexleft;                     \
  58. +   }
  59.   #define FETCH(c, eoferr)             \
  60.     {                         \
  61.       if (! lexleft)                 \
  62. +       regerror(eoferr);            \
  63. +     (c) = (unsigned char) *lexptr++;  \
  64. +     --lexleft;                     \
  65. +   }
  66. + #else
  67. + #define FETCH(c, eoferr)             \
  68. +   {                         \
  69. +     if (! lexleft)                 \
  70.         if (eoferr)                 \
  71.       regerror(eoferr);            \
  72.         else                     \
  73. ***************
  74. *** 295,300 ****
  75. --- 317,323 ----
  76.       (c) = (unsigned char) *lexptr++;  \
  77.       --lexleft;                     \
  78.     }
  79. + #endif sparc
  80.   
  81.   static _token
  82.   lex()
  83. ***************
  84. *** 303,309 ****
  85. --- 326,336 ----
  86.     int invert;
  87.     _charset cset;
  88.   
  89. + #ifdef sparc
  90. +   FETCH0(c);
  91. + #else
  92.     FETCH(c, (char *) 0);
  93. + #endif sparc
  94.     switch (c)
  95.       {
  96.       case '^':
  97.